#ifndef _DETU_MEDIA_VPSS_CHN_IMP_H_
#define _DETU_MEDIA_VPSS_CHN_IMP_H_

#include "vpss_chn.h"
#include "mutex.h"

#include "hi_common.h"
#include "hi_comm_vpss.h"

namespace detu_media
{

class VpssGrpImp;

class VpssChnImp : public VpssChn
{
protected:
    VpssChnImp(const VPSS_GRP grpId);
	
    virtual ~VpssChnImp();

	friend class VpssGrpImp;

public:
    virtual S_Result start(void);
	
    virtual S_Result stop(void);
	
    virtual bool isStarted(void);
	
    virtual S_Result getId(int &id);
    
    virtual S_Result getVpssChnFrame(DT_VIDEO_FRAME_INFO_S* VideoFrameInfo, const int milliSec = -1);
    
    virtual S_Result releaseVpssChnFrame(DT_VIDEO_FRAME_INFO_S* VideoFrameInfo);

private:
    S_Result init(const Json::Value& config);
	
    S_Result deInit(void);

    bool isInited(void);

private:
	constexpr static const VPSS_CHN_ATTR_S defaultChnAttr = 
	{
		.enChnMode 							= VPSS_CHN_MODE_USER,
		.u32Width 							= 3968,
		.u32Height							= 2768,
		.enVideoFormat 						= VIDEO_FORMAT_LINEAR,
		.enPixelFormat 						= PIXEL_FORMAT_YVU_SEMIPLANAR_420,
		.enDynamicRange 					= DYNAMIC_RANGE_SDR8,
		.enCompressMode 					= COMPRESS_MODE_NONE,//COMPRESS_MODE_SEG,
		.stFrameRate 						= 
			{
				.s32SrcFrameRate 			= -1,
				.s32DstFrameRate 			= -1
			},
		.bMirror 							= HI_FALSE,
		.bFlip 								= HI_FALSE,
		.u32Depth 							= 1,
		.stAspectRatio 						= 
			{
				.enMode 					= ASPECT_RATIO_NONE,
				.u32BgColor 				= 0xff,
				.stVideoRect 				= 
					{
						.s32X 				= 0,
						.s32Y 				= 0,
						.u32Width 			= 0,
						.u32Height 			= 0
					}
			}
	};

private:
    VPSS_CHN			fChnId;
    VPSS_GRP			fGrpId;

	VPSS_CHN_ATTR_S 	fChnAttr;

	int                         fRef;
    bool                        fInited;
    detu_infra::Mutex           fMutex;
};

}

#endif
